<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Person List</title>
    </head>
    <body>
        <div class="nav">
	    <span class="menuButton"><g:link class="home" action="home">Home</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Person</g:link></span>
        </div>
        <div class="body">
            <h1>Person List</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                   	        <g:sortableColumn property="id" title="Id" />
                        
                   	        <g:sortableColumn property="userName" title="User Name" />
                        
                   	        <g:sortableColumn property="regNo" title="Reg No" />
                        
                   	        <g:sortableColumn property="firstname" title="Firstname" />
                        
                   	        <g:sortableColumn property="lastname" title="Lastname" />
                        
                   	        <g:sortableColumn property="email" title="Email" />

				<g:sortableColumn property="role" title="Role" />				
				<th class="sortable">Action</th>
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${personList}" status="i" var="person">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td><g:link action="show" id="${person.id}">${fieldValue(bean:person, field:'id')}</g:link></td>
                        
                            <td>${fieldValue(bean:person, field:'userName')}</td>
                        
                            <td>${fieldValue(bean:person, field:'regNo')}</td>
                        
                            <td>${fieldValue(bean:person, field:'firstname')}</td>
                        
                            <td>${fieldValue(bean:person, field:'lastname')}</td>
                        
                            <td>${fieldValue(bean:person, field:'email')}</td>
                        
			    <td>${fieldValue(bean:person, field:'role')}</td>
           <td class="buttons">
                <g:form url="[controller:'person']">
                    <input type="hidden" name="id" value="${person?.id}" />
                    <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
                </g:form>
            </td>

                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
        </div>
    </body>
</html>
